<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>JSON 格式化校验</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="/js/layui/css/layui.css" rel="stylesheet">
    <link rel="stylesheet" href="/css/ku.css">
    <script src="/js/layui/layui.js"></script>
</head>

<body>
    <div class="layui-layout ku-layout-admin">
        <div class="layui-header">
            <div class=" layui-clear">
                <div class="ku-menu-more layui-show-xs-inline-block   layui-hide-sm" lay-header-event="menuLeft">
                    <i class="layui-icon layui-icon-spread-left"></i>
                </div>
                <div class="layui-logo  ">
                    <a class=" layui-font-30 layui-font-white">
                        deloitte
                        <!--<img src="https://digitaltech-dev.deloitte.com.cn/img/logo.iPGv0ASH.png">-->
                    </a>
                </div>

                <ul class="layui-nav ku-menu" id="menu">
                    <!-- 移动端显示 -->
                    <li class="layui-nav-item "><a href="/">首页</a></li>
                    <li class="layui-nav-item ">
                        <a href="javascript:;">数字化审计工具</a>
                        <dl class="layui-nav-child">
                            <dd><a href="javascript:;">数字化审计工具</a></dd>
                            <dd><a href="javascript:;">需求与建议</a></dd>
                            <dd><a href="javascript:;">联系人</a></dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item  "><a href="javascript:;">Audit Pursuit</a></li>
                    <li class="layui-nav-item ">
                        <a href="javascript:;">GenAI</a>
                        <dl class="layui-nav-child">
                            <dd class="layui-this"><a href="javascript:;">用户使用提示</a></dd>
                            <dd><a href="javascript:;">审计应用案例</a></dd>
                            <dd><a href="javascript:;">创新提议</a></dd>
                        </dl>
                    </li>
                </ul>

            </div>
        </div>

        <div class="layui-body">
            <div class="layui-main">

                <blockquote class="layui-elem-quote layui-text">
                    JSON 格式化校验
                </blockquote>

                <div class="layui-row">
                    <script src="/js/json2.js"></script>
                    <script src="/js/jsonlint/jsonlint.js"></script>
                    <style> 
                        #result { padding: 1em; }
                        .pass { background-color: #efe; color: #393; border: 2px solid #393; } 
                        .fail { background-color: #fee; color: #933; border: 2px solid #933; } 
                        textarea { width: 100%; }
                    </style>
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <textarea id="source" rows="20" cols="50" class="layui-textarea"> </textarea>
                        </div>
                    </div>
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <a id="button" class="layui-btn">格式化校验</a>
                            <input type="checkbox" value="yes" id="reformat" /><label for="reformat">格式化</label>
                            <!--<button type="button" class="layui-btn layui-bg-blue">蓝色按钮</button>
                            <button type="button" class="layui-btn layui-bg-orange">橙色按钮</button>
                            <button type="button" class="layui-btn layui-bg-red">红色按钮</button>
                            <button type="button" class="layui-btn layui-bg-purple">紫色按钮</button>
                            <button type="button" class="layui-btn layui-btn-disabled">禁用按钮</button>-->
                        </div>
                    </div>
                    <div class="layui-card">
                        <div class="layui-card-header">结果</div>
                        <div class="layui-card-body">
                            <pre id="result"></pre>
                        </div>
                    </div>


                    <script>
                        window.onload = function () {
                            document.getElementById("button").onclick = function () {
                                try {
                                    var result = jsonlint.parse(document.getElementById("source").value);
                                    if (result) {
                                        console.log(result);

                                        document.getElementById("result").innerHTML = "JSON是有效的！";
                                        document.getElementById("result").className = "pass";
                                        if (document.getElementById("reformat").checked) {
                                            document.getElementById("source").value = JSON.stringify(result, null, "  ");
                                        }
                                    }
                                } catch (e) {
                                    document.getElementById("result").innerHTML = e;
                                    document.getElementById("result").className = "fail";
                                }
                            };
                        }
                    </script>
                </div>
            </div>

            <div class="ku-footer">
                <div class="layui-main">
                    <p class="footer-statement">本站申明：本网站部分工具是站长整合网上已有工具、开源包等，并全部遵循原有协议发布，著作权归属原作者或是团队。</p>
                    <p class="footer-copyright">
                        Copyright © 2011-2021  All rights
                        reserved. &nbsp;&nbsp;&nbsp;&nbsp;<a rel="nofollow" href="https://beian.miit.gov.cn/" style="color: #CCC;" target="_blank">闽ICP备20009294号-1</a>&nbsp;&nbsp;&nbsp;&nbsp;<a rel="nofollow" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=35021102001143" style="color: #CCC;" target="_blank">闽公网安备 35021102001143号</a>
                    </p>
                </div>
            </div>
        </div>

    </div>
    <script>
        //JS
        layui.use(['element', 'layer', 'util'], function () {
            var element = layui.element;
            var layer = layui.layer;
            var util = layui.util;
            var $ = layui.$;

            //头部事件
            util.event('lay-header-event', {
                menuLeft: function (othis) { // 左侧菜单事件
                    //layer.msg('展开左侧菜单的操作', { icon: 0 });
                    var menuHtml = $("#menu").html();
                    layer.open({
                        type: 1,
                        title: false,
                        closeBtn: false,
                        content: '<div class="layui-nav layui-nav-tree" style="width: auto;height: 100%;">' + menuHtml + '</div>',
                        area: ['50%', '100%'],
                        offset: 'lt', // 右上角
                        anim: 'slideRight', // 从右侧抽屉滑出
                        shadeClose: true,
                        scrollbar: true,
                        success: function () {
                            element.render('nav'); //重新对导航进行渲染。注：layui 2.1.6 版本新增
                        }
                    });
                }
            });
        });
    </script>
</body>

</html>